package com.wsx.ones.boot.controller;

import com.wsx.ones.boot.client.DubboxClient;
import com.wsx.ones.boot.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by wangshuaixin on 17/4/9.
 */
@RestController
@RequestMapping("/dubbox")
public class HelloController {

    @Autowired
    private DubboxClient dubboxClient;


    @RequestMapping(
            value = "/cli/{name}",
            method = {RequestMethod.GET}
    )
    public @ResponseBody User getUser(@PathVariable String name) {
        User user = new User();
        user.setName(name);

        User rtn = dubboxClient.getUser(user);
        return rtn;
    }

    @RequestMapping(
            value = "/clis/{name}/{size}",
            method = {RequestMethod.GET}
    )
    public @ResponseBody List<User> getUser(@PathVariable String name, @PathVariable Integer size) {
        User user = new User();
        user.setName(name);

        List<User> rtns = dubboxClient.getUsers(user, size);
        return rtns;
    }
}
